package kr.saeildamil.androidforstudy2.ch23;

import kr.saeildamil.androidforstudy2.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.ViewFlipper;

public class ViewFlipperTest extends Activity {
	ViewFlipper mFlipper;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch23_viewflippertest);
		
		mFlipper = (ViewFlipper) findViewById(R.id.ch23_viewflippertest_flip);
	}
	
	public void mOnClick(View v){
		switch (v.getId()) {
		case R.id.ch23_viewflippertest_btnprev:
			mFlipper.showPrevious();
			break;
		case R.id.ch23_viewflippertest_btnnext:
			mFlipper.showNext();
			break;
		case R.id.ch23_viewflippertest_chkflip:
			if(mFlipper.isFlipping()){
			mFlipper.stopFlipping();
			}else{
				mFlipper.startFlipping();
			}
			break;
		case R.id.ch23_viewflippertest_chkanim:
			if(mFlipper.getInAnimation() == null){
				mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.viewin));
				mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.viewout));
			}else{
				mFlipper.setInAnimation(null);
				mFlipper.setOutAnimation(null);
			}
			break;
		}
	}
}
